<?php
/**
 * Created by IntelliJ IDEA.
 * User: jimmyhsu
 * Date: 2017/4/24
 * Time: 01:55
 */
include ('checkLogin.php');
$course_id = $_GET['course_id'];
$query = mysqli_query($cn, "select * from bulletin join userinfo where course_id='$course_id' and author_id=id");
if (mysqli_num_rows($query) == 0) {
    echo "<center>还没有公告，赶紧<button class='btn' onclick='newBulletin()'>添加</button>吧~</center>";
    die();
}
echo "<table class=\"table table-bordered\"><th>标题</th><th>内容</th><th>发布者</th><th>时间</th><th>删除</th>";
while ($line = mysqli_fetch_assoc($query)) {
    $title = $line['title'];
    $content = $line['content'];
    $author = $line['real_name'];
    $time = $line['release_time'];
    $b_id = $line['b_id'];
    if ($author == 'teacher') {
        $author = "我";
    }
    $time = substr($time, 5, 11); //1990-01-01 12:12:12
    echo "<tr><td>$title</td><td>$content</td><td>$author</td><td>$time</td><td><button type=\"button\" onclick=\"deleteBulletin('$b_id')\" class=\"close\">&times;</button></td></tr>";
}
echo "</table>";